#pragma once
#include "BaseConstraint.h"

class CShapeMatchingConstraint : public CConstraint
{
public:
	CShapeMatchingConstraint(int vNumberOfParticles) : CConstraint(vNumberOfParticles)
	{
		m_x = new Eigen::Vector3d[vNumberOfParticles];
		m_x0 = new Eigen::Vector3d[vNumberOfParticles];
		m_corr = new Eigen::Vector3d[vNumberOfParticles];
		m_w = new double[vNumberOfParticles];
		m_numClusters = new int[vNumberOfParticles];
		m_stiffness = new double[vNumberOfParticles];
	}
	virtual ~CShapeMatchingConstraint()
	{
		delete[] m_x;
		delete[] m_x0;
		delete[] m_corr;
		delete[] m_w;
		delete[] m_numClusters;
		delete[] m_stiffness;
	}

	bool initializeConstraint(CParticleData& vParticleData, const std::vector<int>& vParticleIndices, const std::vector<int>& vNumClusters, const std::vector<double>& vStiffness);
	virtual bool solveConstraintV(CParticleData& vParticleData) override;

private:
	double* m_stiffness;
	Eigen::Vector3d m_restCm;
	Eigen::Matrix3d m_invRestMat;
	double* m_w;
	Eigen::Vector3d* m_x0;
	Eigen::Vector3d* m_x;
	Eigen::Vector3d* m_corr;
	int* m_numClusters;
};